package good.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * AOP实现的第二种方法cglib
 */
public class CligProxy implements MethodInterceptor {
    private Object target;

    public CligProxy(){}

    public CligProxy(Object out){
        this.target=out;
    }

    @Override
    public Object intercept(Object o, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        System.out.println("之前："+method.getName());
        Object ject = methodProxy.invokeSuper(target, args);
        System.out.println("之后："+method.getName());

        return ject;
    }
}
